<div class="text-center bg-primary container-fluid">
    <br>
    <h1><?php echo INSTALL_STEP1_TITLE;?></h1>
    <h3><?php echo INSTALL_STEP1_SUBTITLE;?></h3>
    <br>
</div>
<table class="table table-striped table-hover">
    <thead>
    <tr>
        <th style="width: 30%"><?php echo INSTALL_STEP1_TABLE_COL1;?></th>
        <th style="width: 30%"><?php echo INSTALL_STEP1_TABLE_COL2;?></th>
        <th style="width: 30%"><?php echo INSTALL_STEP1_TABLE_COL3;?></th>
        <th style="width: 10%"><?php echo INSTALL_STEP1_TABLE_COL4;?></th>
    </tr>
    </thead>
    <tbody class="text-left">
    <tr>
        <td><?php echo INSTALL_STEP1_TABLE_ROW1;?></td>
        <td><a id="php_version_tj">6.7</a></td>
        <td><a id="php_version"><?php echo PHP_VERSION;?></a></td>
        <td><i id="php_version_icon"></i></td>
    </tr>
    <tr>
        <td><?php echo INSTALL_STEP1_TABLE_ROW2;?></td>
        <td><a id="mysqli_tj"><?php echo INSTALL_STEP1_TABLE_SUPPORT;?></a></td>
        <td>
            <a id="mysqli_sp"><?php echo extension_loaded("mysqli")?INSTALL_STEP1_TABLE_SUPPORT:INSTALL_STEP1_TABLE_UNSUPPORT;?></a>
        </td>
        <td><i id="mysqli_icon"></i></td>
    </tr>
    <tr>
        <td><?php echo INSTALL_STEP1_TABLE_ROW3;?></td>
        <td><a id="date_tj"><?php echo INSTALL_STEP1_TABLE_SUPPORT;?></a></td>
        <td>
            <a id="date_sp"><?php echo extension_loaded("date")?INSTALL_STEP1_TABLE_SUPPORT:INSTALL_STEP1_TABLE_UNSUPPORT;?></a>
        </td>
        <td><i id="date_icon"></i></td>
    </tr>
    <tr>
        <td><?php echo INSTALL_STEP1_TABLE_ROW4;?></td>
        <td><a id="hash_tj"><?php echo INSTALL_STEP1_TABLE_SUPPORT;?></a></td>
        <td>
            <a id="hash_sp"><?php echo extension_loaded("hash")?INSTALL_STEP1_TABLE_SUPPORT:INSTALL_STEP1_TABLE_UNSUPPORT;?></a>
        </td>
        <td><i id="hash_icon"></i></td>
    <tr>
        <td><?php echo INSTALL_STEP1_TABLE_ROW5;?></td>
        <td><a id="zip_tj"><?php echo INSTALL_STEP1_TABLE_SUPPORT;?></a></td>
        <td>
            <a id="zip_sp"><?php echo extension_loaded("zip")?INSTALL_STEP1_TABLE_SUPPORT:INSTALL_STEP1_TABLE_UNSUPPORT;?></a>
        </td>
        <td><i id="zip_icon"></i></td>
    </tr>
    <tr>
        <td><?php echo INSTALL_STEP1_TABLE_ROW6;?></td>
        <td><a id="curl_tj"><?php echo INSTALL_STEP1_TABLE_SUPPORT;?></a></td>
        <td>
            <a id="curl_sp"><?php echo extension_loaded("curl")?INSTALL_STEP1_TABLE_SUPPORT:INSTALL_STEP1_TABLE_UNSUPPORT;?></a>
        </td>
        <td><i id="curl_icon"></i></td>
    </tr>
    <tr>
        <td><?php echo INSTALL_STEP1_TABLE_ROW7;?></td>
        <td><a id="write_tj"><?php echo INSTALL_STEP1_TABLE_SUPPORT;?></a></td>
        <td>
            <a id="write_sp"><?php echo is_writeable('./')?INSTALL_STEP1_TABLE_SUPPORT:INSTALL_STEP1_TABLE_UNSUPPORT;?></a>
        </td>
        <td><i id="write_icon"></i></td>
    </tr>
    </tbody>
</table>
<div class="text-center bg-primary container-fluid">
    <br>
    <div align="center">
        <button class="btn btn-primary btn-lg" id="back"><?php echo INSTALL_BUTTON_BACK;?></button>
        <button class="btn btn-primary btn-lg" id="next"><?php echo INSTALL_BUTTON_NEXT;?></button>
    </div>
    <br>
</div>
<script>
    $(document).ready(function () {
        $("#next").click(function () {
            self.location.href = "./?/install&step=2";
        });
        $("#back").click(function () {
            self.location.href = "./?/install";
        });


        var result = true;
        var php_version_tj = $("#php_version_tj").text();
        var php_version = $("#php_version").text();
        var pvtj_a = php_version_tj.split(".");
        var pv_a = php_version.split(".");
        var pv_st = false;
        if (pvtj_a[0] > pv_a[0]) {
            pv_st = false;
        } else if (pvtj_a[0] === pv_a[0]) {
            if (pvtj_a[1] > pv_a[1]) {
                pv_st = false;
            } else if (pvtj_a[1] === pv_a[1]) {
                if (pvtj_a[2] > pv_a[2]) {
                    pv_st = false;
                } else if (pvtj_a[2] === pv_a[2]) {
                    pv_st = true;
                } else if (pvtj_a[2] < pv_a[2]) {
                    pv_st = true;
                }
            } else if (pvtj_a[1] < pv_a[1]) {
                pv_st = true;
            }
        } else if (pvtj_a[0] < pv_a[0]) {
            pv_st = true;
        }
        if (pv_st) {
            $("#php_version_icon").addClass("icon-check-circle icon-2x install_icon_green");
        } else {
            result = false;
            $("#php_version_icon").addClass("icon-remove-sign icon-2x install_icon_red");
        }

        if ($("#mysqli_tj").text() === $("#mysqli_sp").text()) {
            $("#mysqli_icon").addClass("icon-check-circle icon-2x install_icon_green");
        } else {
            if ($("#write_tj").text() !== $("#write_sp").text()) {
                result = false;
            }
            $("#mysqli_icon").addClass("icon-remove-sign icon-2x install_icon_red");
        }

        if ($("#date_tj").text() === $("#date_sp").text()) {
            $("#date_icon").addClass("icon-check-circle icon-2x install_icon_green");
        } else {
            result = false;
            $("#date_icon").addClass("icon-remove-sign icon-2x install_icon_red");
        }

        if ($("#hash_tj").text() === $("#hash_sp").text()) {
            $("#hash_icon").addClass("icon-check-circle icon-2x install_icon_green");
        } else {
            result = false;
            $("#hash_icon").addClass("icon-remove-sign icon-2x install_icon_red");
        }

        if ($("#zip_tj").text() === $("#zip_sp").text()) {
            $("#zip_icon").addClass("icon-check-circle icon-2x install_icon_green");
        } else {
            result = false;
            $("#zip_icon").addClass("icon-remove-sign icon-2x install_icon_red");
        }

        if ($("#curl_tj").text() === $("#curl_sp").text()) {
            $("#curl_icon").addClass("icon-check-circle icon-2x install_icon_green");
        } else {
            result = false;
            $("#curl_icon").addClass("icon-remove-sign icon-2x install_icon_red");
        }

        if ($("#write_tj").text() === $("#write_sp").text()){
            $("#write_icon").addClass("icon-check-circle icon-2x install_icon_green");
        }else {
            result = false;
            $("#write_icon").addClass("icon-remove-sign icon-2x install_icon_red");
        }
        if (!result) {
            $("#next").attr("disabled",true);
        }
    });
</script>